package com.xypower.service.impl;

import com.xypower.mapper.StudentMapper;
import com.xypower.pojo.Student;
import com.xypower.service.StudentService;
import com.xypower.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class StudentServiceImpl implements StudentService {
    private StudentMapper studentMapper;
    public StudentServiceImpl(){
        //1. 得到sqlsession
        SqlSession sqlSession = MyBatisUtil.getSqlSession(true);
        //2. 得到studentMapper
        studentMapper = sqlSession.getMapper(StudentMapper.class);
    }
    @Override
    public List<Student> findAll() {
        return studentMapper.findAll();
    }

    @Override
    public void insert(Student student) {
        studentMapper.insert(student);
    }

    @Override
    public void update(Student student) {
        studentMapper.update(student);
    }

    @Override
    public void delete(String sid) {
        studentMapper.delete(sid);
    }
}
